<template>
  <div class="cart">
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{cartLength}})</div>
    </nav-bar>
    <cart-list></cart-list>
    <cart-button-bar></cart-button-bar>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import NavBar from 'components/common/navbar/NavBar.vue'
import CartList from './childComps/CartList.vue'
import CartButtonBar from './childComps/CartButtonBar.vue'

export default {
  name: "Cart",
  components: {
    NavBar,
    CartList,
    CartButtonBar,
  },
  computed: {
    // cartLength () {
    //   return this.$store.getters.cartLength
    // }
    ...mapGetters(['cartLength'])//能直接获取getters.js里的方法，不用写上面的那个方法
  }

}
</script>

<style scoped>
.cart {
  height: 100vh;
}
.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
}
</style>
